package com.szh.zx.gaoDingJavaBook.yitu.one;

public class TreeMapLianxi {
	Student222 s1 = new Student222(12,"adafd");
}
class Student222 implements Comparable{
	int age;
	String name;

	public Student222(int age, String name) {
		this.age = age;
		this.name = name;
	}

	@Override
	public String toString() {
		return "Student222{" +
				"age=" + age +
				", name='" + name + '\'' +
				'}';
	}

	@Override
	public int compareTo(Object o) {
		Student222 s1 = this;
		Student222 s2 = (Student222) o;
		if (!s1.name.equals(s2.name)){
			return s1.name.compareTo(s2.name);
		}
		if (s1.age != s2.age){
			return s1.age - s2.age;
		}
		return 1;
	}
}